package utils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import java.util.Objects;

import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;

import oracle.adf.view.rich.component.rich.input.RichSelectManyCheckbox;

public class ControlsCheckBoxMB {
    private RichSelectManyCheckbox checkBoxMany;
    private List<SelectItem> lista;
    private RichSelectManyCheckbox checkBoxMany2;

    public ControlsCheckBoxMB() {
        lista = new ArrayList(4);
        lista.add(new SelectItem("Crno"));
        lista.add(new SelectItem("Bijelo"));
        lista.add(new SelectItem("Plavo"));
        lista.add(new SelectItem("Crveno"));               
    }

    public void setCheckBoxMany(RichSelectManyCheckbox checkBoxMany) {
        this.checkBoxMany = checkBoxMany;
    }

    public RichSelectManyCheckbox getCheckBoxMany() {
        return checkBoxMany;
    }

    public void setLista(List<SelectItem> lista) {
        this.lista = lista;
    }

    public List<SelectItem> getLista() {
        return lista;
    }

    public void valueChanged(ValueChangeEvent valueChangeEvent) {
        // Add event code here...       
        ArrayList lista = new ArrayList(Arrays.asList(valueChangeEvent.getNewValue()));       
        System.out.println(valueChangeEvent.getNewValue());
        for(int i=0;i<lista.size();i++){
            System.out.println("Element: "+lista.get(i));
        }
    }

    public void resetCheckbox(ActionEvent actionEvent) {
        // Add event code here...
        checkBoxMany2.setValue(null);
       
    }

    public void setCheckBoxMany2(RichSelectManyCheckbox checkBoxMany2) {
        this.checkBoxMany2 = checkBoxMany2;
    }

    public RichSelectManyCheckbox getCheckBoxMany2() {
        return checkBoxMany2;
    }

    public void setCheckBox(ActionEvent actionEvent) {
        // Add event code here...                
        Object [] obj = new Object[2];
        obj[0]="Crno";
        obj[1]="Plavo";
        checkBoxMany2.setValue(obj);                    
    }


    public void getChechBox(ActionEvent actionEvent) {
        // Add event code here...
        System.out.println(checkBoxMany2.getValue());
    }

    public void setVal(ActionEvent actionEvent) {
        // Add event code here...
    }
}
